package GameControll;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.lwjgl.opengl.GL11;

import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class Starter {

	public Starter() {
		initNatives();
		initDisplay(800, 600);
		initGL();
		initGame();
		gameLoop();
		cleanUp();
	}

	private void initNatives() {
		System.setProperty("org.lwjgl.librarypath", new File(new File(System.getProperty("user.dir"), "native"), LWJGLUtil.getPlatformName()).getAbsolutePath());
		System.setProperty("net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath"));
	}

	private void initDisplay(int x, int y) {
			try {
				Display.setDisplayMode(new DisplayMode(x, y));
				Display.setVSyncEnabled(true);
				Display.create();
				Keyboard.create();
			} catch (LWJGLException e) {
				System.out.println(e);
			}
	}

	private void initGL() {
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glShadeModel(GL11.GL_SMOOTH);
		GL11.glLoadIdentity();
		GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), -1, 1);
		GL11.glDisable(GL11.GL_DEPTH_TEST);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glEnable(GL11.GL_BLEND);
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		GL11.glAlphaFunc(GL11.GL_GREATER, 0f);
		GL11.glClearColor(0,0,0,0);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
	}
	
	private void initGame() {
		
	}

	private void gameLoop() {
		while (!Display.isCloseRequested()) {
			//getInput();
			//update();
			//render();
		}
	}

	private void cleanUp() {
		Display.destroy();
		Keyboard.destroy();
	}

}
